<?php	
	/*
	* Author: Chau Dang Huy
	* Date: 2013-02-12
	* Script: Admin Panel
	* Function: Manage product, CRUD, search index.
	*/	

	require_once('include/header.php');
?>
<html>
	<head>
		<meta charset="UTF-8" />
                <title>Duc Ngoc O2</title>
		<style type="text/css" title="currentStyle">
    		@import "media/css/demo_page.css";
			@import "media/css/demo_table.css";
			@import "http://www.datatables.net/media/css/site_jui.ccss";
			@import "media/css/demo_table_jui.css";
			@import "media/css/themes/base/jquery-ui.css";
			@import "media/css/themes/smoothness/jquery-ui-1.7.2.custom.css";
			/*
			 * Override styles needed due to the mix of three different CSS sources! For proper examples
			 * please see the themes example in the 'Examples' section of this site
			 */
			.dataTables_info { padding-top: 0; }
			.dataTables_paginate { padding-top: 0; }
			.css_right { float: right; }
			#example_wrapper .fg-toolbar { font-size: 0.8em }
			#theme_links span { float: left; padding: 2px 10px; }
		</style>
		<!-- Script -->
		<script type="text/javascript" src="<?php echo WEB_UTILS_URL?>/media/js/complete.js"></script>
		<script src="<?php echo WEB_UTILS_URL?>/media/js/jquery.min.js" type="text/javascript"></script>
        <script src="<?php echo WEB_UTILS_URL?>/media/js/jquery.dataTables.min.js" type="text/javascript"></script>
		<script type="text/javascript" src="<?php echo WEB_UTILS_URL?>/media/js/jquery.dataTables.editable.js"></script>
		<script src="<?php echo WEB_UTILS_URL?>/media/js/jquery.jeditable.js" type="text/javascript"></script>
        <script src="<?php echo WEB_UTILS_URL?>/media/js/jquery-ui.js" type="text/javascript"></script>
        <script src="<?php echo WEB_UTILS_URL?>/media/js/jquery.validate.js" type="text/javascript"></script>
        <!-- Script -->        
		<script type="text/javascript" charset="utf-8">
			$(document).ready( function () {
				var id = -1;//simulation of id
				$('#example').dataTable({ bJQueryUI: true,
											"sAjaxSource": "products_data.php",
											"sPaginationType": "full_numbers"
				}).makeEditable({
									sUpdateURL: "script/UpdateData.php",
				                    sAddURL: "script/AddData.php",
				                    sAddHttpMethod: "GET",
				                    sDeleteHttpMethod: "GET",
									sDeleteURL: "script/DeleteData.php",
				                    			"aoColumns": [
				                    							{ 	cssclass: "required" },
				                    							{},
				                    							{
				                							        indicator: 'Saving platforms...',
				                                   					tooltip: 'Click to edit platforms',
									 								type: 'textarea',
				                               						submit:'Save changes'
				                    							},
				                    							{
				                                                    indicator: 'Saving Engine Version...',
				                                                    tooltip: 'Click to select engine version',
				                                                    loadtext: 'loading...',
				                           					        type: 'select',
				                               						onblur: 'cancel',
																	submit: 'Ok',
				                                                    loadurl: 'EngineVersionList.php',
																	loadtype: 'GET'
				                    							},
				                    							{
				                                                	indicator: 'Saving CSS Grade...',
				                                                    tooltip: 'Click to select CSS Grade',
				                                                    loadtext: 'loading...',
				                           					        type: 'select',
				                               						onblur: 'submit',
				                                                	data: "{'':'Please select...', 'A':'A','B':'B','C':'C'}"
				                                                }
															],
									oAddNewRowButtonOptions: {	label: "Add...",
																icons: {primary:'ui-icon-plus'} 
															},
									oDeleteRowButtonOptions: {	label: "Remove", 
																icons: {primary:'ui-icon-trash'}
															},

									oAddNewRowFormOptions: { 	
				                                                title: 'Add New Product',
																show: "blind",
																hide: "explode",
				                                                modal: true
															}	,
									sAddDeleteToolbarSelector: ".dataTables_length"								
														});
								
								});			
		</script>
	</head>
	<body>		
		<?php 			
			$actions = array(
					'product' => array('title' => 'Product', 'href' => ''),					
				);
			// Product actions
			$product_actions = '<a href="'.$_SERVER['PATH_INFO'].'?test=local&addProduct=yes">Add Product</a>';

			$body_tpl = $function->prepareHeader($body_tpl);			
			
			// Product form
			$body_tpl = str_replace('#add_product_form', $add_product_form, $body_tpl);
						
			// Product table
			$body_tpl = str_replace('#table', $product_table, $body_tpl);			

			echo $body_tpl;
		?>				
	</body>
</html>
